package com.atgiogi.meiniantour.mobile.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.atguigu.meinian.constant.MessageConstant;
import com.atguigu.meinian.constant.RedisConstant;
import com.atguigu.meinian.constant.RedisMessageConstant;
import com.atguigu.meinian.pojo.Setmeal;
import com.atguigu.meinian.pojo.TravelGroup;
import com.atguigu.meinian.service.OrderSerivce;
import com.atguigu.meinian.service.SetmealService;
import com.atguigu.meinian.service.TravelGroupService;
import com.atguigu.meinian.util.SMSUtils;
import com.atguigu.meinian.util.ValidateCodeUtils;
import com.atguigu.meinian.vo.R;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import redis.clients.jedis.JedisPool;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zbystart
 * @create 2021-06-23 19:06
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference
    private SetmealService setmealService;

    @Reference
    private TravelGroupService travelGroupService;

    @Reference
    private OrderSerivce orderSerivce;

    @Autowired
    private JedisPool jedisPool;

    @RequestMapping("/getSetmeal")
    public R getSetmeal() {
        try {
            List<Setmeal> list = setmealService.queryAllSetmeals();
            return R.ok(MessageConstant.GET_SETMEAL_LIST_SUCCESS,list);
        } catch (Exception e) {
            return R.error(MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
    }

    @GetMapping("/findById")
    public R findById(Integer id) {
        try {
            Setmeal setmeal = setmealService.findTravelGroupsBySetmealId(id);
            return R.ok(MessageConstant.QUERY_TRAVELGROUP_SUCCESS,setmeal);
        } catch (Exception e) {
            return R.error(MessageConstant.QUERY_TRAVELGROUP_FAIL);
        }
    }

    @GetMapping("/get")
    public R get(Integer id) {
        try{
            Setmeal setmeal = setmealService.querySetmealInfoById(id);
            return R.ok(MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error(MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }


}
